<?php
/**
 *@作者:MissZhang
 *@邮箱:<787727147@qq.com>
 *@创建时间:2022/10/10 15:59
 *@说明:进货商品模型
 */
namespace app\common\model;


use think\Model;

class StockGoods extends Model
{
    protected $pk = "goods_id";
    // 定义时间戳字段名
    protected $createTime = 'add_time';
    //修改format类型
    protected $dateFormat = "Y-m-d H:i:s";
    protected $type=[
        'goods_imgs'     =>  'serialize',
        'market_price'     =>  'float',
        'goods_price'     =>  'float',
        'ship_price'    =>  'float',
        'sort'    =>  'integer',
    ];
    public function getPkAttr($value,$data) {
        return $this->pk;
    }
    public function qianbao(){
        return $this->hasOne(Wallet::class, 'id','wid');
    }
    public function getSaleTextAttr($value,$data) {
        if ($data['is_on_sale']==1){
            return '是';
        }
        return '否';
    }
}
